package com.usian.controller;

import com.usian.pojo.Account;
import com.usian.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/account")
public class AccountController {

    @Autowired
    public AccountService accountService;

    /**
     * 指定id扣减金额
     *
     * @param account
     * @return
     */
    @PostMapping("/DeductionAmount")
    public String DeductionAmount(@RequestBody Account account){
        accountService.DeductionAmount(account);
        return "succ";
    }

    /**
     * 根据用户id查询用户账户对象
     *
     * @param userId
     * @return
     */
    @GetMapping("/findByUserId/{userId}")
    public Account findByUserId(@PathVariable Integer userId){
        return accountService.findByUserId(userId);
    }


}
